﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Xinkui.Common {
    /// <summary>
    /// 具有无参构造函数类型的单例容器
    /// </summary>
    public static class Singleton<T> where T : class, new() {
        private static readonly T instance;


        static Singleton() {
            try {
                instance = new T();
            }
            catch (Exception e) {
                //TODO:Log
            }
        }

        /// <summary>
        /// 返回相同实例
        /// </summary>
        public static T Instance {
            get { return instance; }
        }
    }
}
